package com.dahua.messagesyncsh.service.Impl;

import com.dahua.messagesyncsh.entity.EquipmentChange;
import com.dahua.messagesyncsh.criteria.EquipmentChangeQueryCriteria;
import com.dahua.messagesyncsh.mapper.EquipmentChangeMapper;
import com.dahua.messagesyncsh.service.EquipmentChangeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class EquipmentChangeServiceImpl implements EquipmentChangeService {
    @Resource
    private EquipmentChangeMapper equipmentChangeMapper;

    @Override
    public List<EquipmentChange> listUnhandled() {
        EquipmentChangeQueryCriteria criteria = new EquipmentChangeQueryCriteria();
        criteria.setProcessFlag(0);
        return equipmentChangeMapper.list(criteria);
    }

    @Override
    public void handle(EquipmentChange criteria) {
        criteria.setProcessFlag(1);
        criteria.setProcessDate(Timestamp.valueOf(LocalDateTime.now()));
        if (criteria.getBk1() == null){
            criteria.setBk1("ok");
        }
        equipmentChangeMapper.handle(criteria);
    }
}
